/*
 * inotify-sync - a simple file synchronizer and file system watcher
 * Copyright (C) 2010-2011, inotify-sync developers and inotify-sync contributors
 * Copyright (C) 2010-2011, Cohesion Network Security Studio
 *
 * inotify-sync is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * inotify-sync is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with inotify-sync; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */


#include "Profile.h"

Profile::Profile(string profile_name,
		unsigned short sync_mode,
		unsigned short log_mode,
		string log_path,
		unsigned short watch_hide,
		string src_path,
		string dest_path,
		unsigned short sync_create_file,
		unsigned short sync_create_dir,
		unsigned short sync_delete,
		unsigned short sync_modify,
		unsigned short sync_moved_from,
		unsigned short sync_moved_to,
		unsigned short sync_move_inside)
:
profile_name(profile_name),
sync_mode(sync_mode),
log_mode(log_mode),
log_path(log_path),
watch_hide(watch_hide),
src_path(src_path),
dest_path(dest_path),
sync_create_file(sync_create_file),
sync_create_dir(sync_create_dir),
sync_delete(sync_delete),
sync_modify(sync_modify),
sync_moved_from(sync_moved_from),
sync_moved_to(sync_moved_to),
sync_move_inside(sync_move_inside)
{}

Profile::Profile()
:
profile_name(""),
sync_mode(0),
log_mode(0),
log_path(""),
watch_hide(0),
src_path(""),
dest_path(""),
sync_create_file(0),
sync_create_dir(0),
sync_delete(0),
sync_modify(0),
sync_moved_from(0),
sync_moved_to(0),
sync_move_inside(0)
{}

Profile::~Profile()
{}

void
Profile::print()
{
	printf("Profile name:\t\t%s\n",profile_name.c_str());
	printf("sync mode:\t\t%s\n",get_sync_mode_cstr());
	printf("log mode:\t\t%s\n",get_log_mode_cstr());
	printf("log path:\t\t%s\n",log_path.c_str());
	printf("watch hide:\t\t%s\n",y_or_n(watch_hide));
	printf("src path:\t\t%s\n",src_path.c_str());
	printf("dest path:\t\t%s\n",dest_path.c_str());
	printf("sync create file:\t%s\n",y_or_n(sync_create_file));
	printf("sync create dir:\t%s\n",y_or_n(sync_create_dir));
	printf("sync delete:\t\t%s\n",y_or_n(sync_delete));
	printf("sync modify:\t\t%s\n",y_or_n(sync_modify));
	printf("sync moved from:\t%s\n",y_or_n(sync_moved_from));
	printf("sync moved to:\t\t%s\n",y_or_n(sync_moved_to));
	printf("sync move inside:\t%s\n",y_or_n(sync_move_inside));
}

string
Profile::get_profile_name()const
{
	return profile_name;
}

void
Profile::set_profile_name(string profile_name)
{
	this->profile_name=profile_name;
}

unsigned short
Profile::get_sync_mode()const
{
	return sync_mode;
}

const char *
Profile::get_sync_mode_cstr()const
{
	switch(sync_mode)
	{
	case RSYNC:
		return "RSYNC";
	case ASYNC:
		return "ASYNC";
	case NSYNC:
		return "NSYNC";
	}
}

string
Profile::get_sync_mode_str()const
{
	return string(get_sync_mode_cstr());
}

void
Profile::set_sync_mode(unsigned short sync_mode)
{
	this->sync_mode=sync_mode;
}

unsigned short
Profile::get_log_mode()const
{
	return log_mode;
}

const char *
Profile::get_log_mode_cstr()const
{
	switch(log_mode)
	{
	case STD:
		return "STD";
	case XML:
		return "XML";
	}
}

string
Profile::get_log_mode_str()const
{
	return string(get_log_mode_str());
}

void
Profile::set_log_mode(unsigned short log_mode)
{
	this->log_mode=log_mode;
}

string
Profile::get_log_path()const
{
	return this->log_path;
}

void
Profile::set_log_path(string log_path)
{
	this->log_path=log_path;
}

unsigned short
Profile::get_watch_hide()const
{
	return watch_hide;
}

const char *
Profile::get_watch_hide_cstr()const
{
	return y_or_n(watch_hide);
}

string
Profile::get_watch_hide_str()const
{
	return string(y_or_n(watch_hide));
}
	
void
Profile::set_watch_hide(unsigned short watch_hide)
{
	this->watch_hide=watch_hide;
}

string
Profile::get_src_path()const
{
	return src_path;
}

void
Profile::set_src_path(string src_path)
{
	this->src_path=src_path;
}

string
Profile::get_dest_path()const
{
	return dest_path;
}

void
Profile::set_dest_path(string dest_path)
{
	this->dest_path=dest_path;
}

string
Profile::get_tmp_path()const
{
	return dest_path+"/.inotify-sync";
}

unsigned short
Profile::get_sync_create_file()const
{
	return sync_create_file;
}

void
Profile::set_sync_create_file(unsigned short sync_create_file)
{
	this->sync_create_file=sync_create_file;
}

unsigned short
Profile::get_sync_create_dir()const
{
	return sync_create_dir;
}

void
Profile::set_sync_create_dir(unsigned short sync_create_dir)
{
	this->sync_create_dir=sync_create_dir;
}

unsigned short
Profile::get_sync_delete()const
{
	return sync_delete;
}

void
Profile::set_sync_delete(unsigned short sync_delete)
{
	this->sync_delete=sync_delete;
}

unsigned short
Profile::get_sync_modify()const
{
	return sync_modify;
}

void
Profile::set_sync_modify(unsigned short sync_modify)
{
	this->sync_modify=sync_modify;
}

unsigned short
Profile::get_sync_moved_from()const
{
	return sync_moved_from;
}

void
Profile::set_sync_moved_from(unsigned short sync_moved_from)
{
	this->sync_moved_from=sync_moved_from;
}

unsigned short
Profile::get_sync_moved_to()const
{
	return sync_moved_to;
}

void
Profile::set_sync_moved_to(unsigned short sync_moved_to)
{
	this->sync_moved_to=sync_moved_to;
}

unsigned short
Profile::get_sync_move_inside()const
{
	return sync_move_inside;
}

void
Profile::set_sync_move_inside(unsigned short sync_move_inside)
{
	this->sync_move_inside=sync_move_inside;
}

const char*
Profile::y_or_n(unsigned short val)const
{
	switch(val)
	{
	case YES:
		return "YES";
	case NO:
		return "NO";
	}
}
